/*
 * @Author: 清羽
 * @Date: 2022-08-23 16:32:26
 * @LastEditTime: 2022-09-08 14:16:55
 * @LastEditors: you name
 * @Description: 
 */
import request from '@/utils/request'
import { business } from '@/utils/base'

// 获取 店铺 分类列表 (子项可选)
export function getMyBusinessCate () {
	return request({
		url: `${business}/product/category`,
		method: "get"
	})
}

// 获取 商城 分类列表
export function getCate () {
	return request({
		url: "/product/category/list",
		method: "get"
	})
}

// 创建商品
export function addProduct (data) {
	return request({
		url: `${business}/product/add`,
		method: "post",
		data
	})
}

export function addProductInfo (params, data) {
	return request({
		url: `${business}/product/add/info`,
		method: "post",
		data,
		params
	})
}

// 获取商品信息
export function getProductInfo (params) {
	return request({
		url: `${business}/product/info`,
		method: "get",
		params
	})
}

// 修改商品信息
export function updateProductInfo (params, data) {
	return request({
		url: `${business}/product/info/update`,
		method: "post",
		data,
		params
	})
}

// 获取商品图片素材
export function getProductPic (params) {
	return request({
		url: `${business}/product/pic`,
		method: "get",
		params
	})
}

// 上传图片素材
export function uploadProductPic (params) {
	return request({
		url: `${business}/product/pic/upload`,
		method: "post",
		data: params,
		headers: {
			'Content-Type': 'multipart/form-data'
		}

	})
}

// 删除图片素材
export function delProductPic (data) {
	return request({
		url: `${business}/product/pic/del`,
		method: "post",
		data
	})
}

// 添加商品规格组名
export function addProductGroupName (data) {
	return request({
		url: `${business}/product/param/group/add`,
		method: "post",
		data
	})
}

// 获取商品规格
export function getProductParam (params) {
	return request({
		url: `${business}/product/param`,
		method: "get",
		params
	})
}

// 删除商品规格组
export function delProductParamGroup (params) {
	return request({
		url: `${business}/product/param/group/delete`,
		method: "post",
		params
	})
}

// 添加规格值
export function addProductParamKey (params, data) {
	return request({
		url: `${business}/product/param/key/add`,
		method: "post",
		data,
		params
	})
}

// 删除规格值
export function delProductParamKey (params) {
	return request({
		url: `${business}/product/param/key/delete`,
		method: "post",
		params
	})
}

// 提交商品规格、价格等内容
export function submitProductParam (params, data) {
	return request({
		url: `${business}/product/param/value/add`,
		method: "post",
		data,
		params
	})
}

// 获取商品规格、价格等内容
export function getProductParamValue (params) {
	return request({
		url: `${business}/product/param/value`,
		method: "get",
		params
	})
}

// 获取富文本内容
export function getProductEditor (params) {
	return request({
		url: `${business}/product/editor`,
		method: "get",
		params
	})
}

// 获取商品列表
export function getProductList (params) {
	return request({
		url: `${business}/products`,
		method: "get",
		params
	})
}

//  提交商品审核
export function submitProductCheck (params) {
	return request({
		url: `${business}/product/auditSub/${params}`,
		method: 'get'
	})
}

// 删除商品
export function delProduct (productId) {
	return request({
		url: `${business}/product/delete/${productId}`,
		method: 'get'
	})
}

// 恢复删除
export function recoverProduct (productId) {
	return request({
		url: `${business}/product/recover/${productId}`,
		method: 'get'
	})

}

// 商品上架
export function upShelfProduct (productId) {
	return request({
		url: `${business}/product/up/${productId}`,
		method: 'get'
	})
}

export function stepShelfProduct (productId) {
	return request({
		url: `${business}/product/step/${productId}`,
		method: 'get'
	})
}